#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 10009; //100005

int arr[N];
int n,sum;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	sort(arr+1,arr+1+n);
	for(int i=1;i<n;i++)
	{
		arr[i+1] = arr[i] + arr[i+1];
		sum += arr[i+1];
		//in a[i+1] -> a[i+2]---a[n];
		for(int j=i+1;j<n;j++)
			if(arr[j] > arr[j+1])
				swap(arr[j],arr[j+1]);
			else
				break;
	}
	cout << sum;
	return 0;
}
